package com.guoxin.part1.chapter6;

import java.util.concurrent.TimeUnit;

/**
 * 复制Thread 数组
 *
 * @author guoxin
 * @date 2019/8/28
 */
public class ThreadGroupEnumerateThreaGroups {
    public static void main(String[] args) throws InterruptedException {
        // 创建一个ThreadGroup
        ThreadGroup myGroup1 = new ThreadGroup("MyGroup1");
        ThreadGroup myGroup2 = new ThreadGroup(myGroup1, "MyGroup2");

        TimeUnit.MILLISECONDS.sleep(2);
        ThreadGroup mainGroup = Thread.currentThread().getThreadGroup();

        ThreadGroup[] list = new ThreadGroup[mainGroup.activeGroupCount()];
        int recurseSize = mainGroup.enumerate(list);
        System.out.println(recurseSize);

        recurseSize = mainGroup.enumerate(list, false);
        System.out.println(recurseSize);
    }
}
